@extends('index')

@section('content')
<div role="tabpanel">

  <!-- Nav tabs -->
  <ul class="nav nav-tabs" role="tablist" role="tablist" id="myTab">
    <li role="presentation" class="active"><a href="#companys" aria-controls="companys" role="tab" data-toggle="tab">品牌管理</a></li>
    <li role="presentation"><a href="#cars" aria-controls="cars" role="tab" data-toggle="tab">车型管理</a></li>
    <li role="presentation"><a href="#clients" aria-controls="clients" role="tab" data-toggle="tab">客户管理</a></li>
  </ul>

  <!-- Tab panes -->
  <div class="tab-content">



    <div role="tabpanel" class="tab-pane active" id="companys">
      <br>
      <div id="CompanysTable"></div>
    </div>


    <div role="tabpanel" class="tab-pane" id="cars">
      <br>
      <div id="CarsTable"></div>
    </div>
    <div role="tabpanel" class="tab-pane" id="clients">
      <br>
      <div id="ClientsTable"></div>
    </div>
  </div>

</div>
@stop

@section('script')
<script type="text/javascript">
$(function () {
  $("#jichu").addClass("active");

  $('#CompanysTable').jtable({
    title: '厂商管理',
    actions: {
        listAction: '/getcompanyslist',
        createAction: '/addcompany',
        updateAction: '/editecompany',
        deleteAction: '/deletecompany'
    },
    fields: {
        id: {
            key: true,
            list: false
        },
        厂商名: {
            title: '厂商名',
        },
        地址: {
            title: '地址',

        },
    }
  });
  $('#CompanysTable').jtable('load');

  $('#CarsTable').jtable({
    title: '车型管理',
    actions: {
        listAction: '/getcarslist',
        createAction: '/addcar',
        updateAction: '/editecar',
        deleteAction: '/deletecar'
    },
    fields: {
        id: {
            key: true,
            list: false
        },
        型号: {
            title: '型号',
        },
        公司: {
            title: '公司',
            options: '/getcompanys'

        },
        进货价格: {
            title: '进货价格',
        },
        出售价格: {
            title: '出售价格',
        },
        年份: {
            title: '年份',
        },
    }
  });
  $('#CarsTable').jtable('load');

  $('#ClientsTable').jtable({
    title: '厂商管理',
    actions: {
        listAction: '/getclientslist',
        createAction: '/addclient',
        updateAction: '/editeclient',
        deleteAction: '/deleteclient'
    },
    fields: {
        id: {
            key: true,
            list: false
        },
        姓名: {
            title: '姓名',
        },
        性别: {
            options: { 1: '男', 2: '女', 0: '未定义' },
            title: '性别',
        },
        地址: {
            title: '地址',
        },
        电话: {
            title: '电话',
        },
        年龄: {
            title: '年龄',
            input: function (data) {
        if (data.record) {
            return '<input type="text" name="年龄" style="width:200px" value="' + data.record.年龄 + '"/>';
        } else {
            return '<input type="text" name="年龄" style="width:200px" value=""/>';
        }
    }
        },
    }
  });
  $('#ClientsTable').jtable('load');

});


</script>
@stop